package com.example.demo.dao;

import com.example.demo.entity.Comment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * 评论的数据库操作类
 */
public interface CommentDao extends JpaRepository<Comment,Integer> {

    // 获取圈子的评论
    @Query(value = "select c.*,u.nickname,u.avtar from comment c join user u on u.id = c.userId where circleId=?1"
            ,nativeQuery = true)
    List<Map<String,Object>> getComment(int circleId);
}
